package com.yyg.boot.web;

import com.yyg.boot.entity.Employee;
import com.yyg.boot.mail.IMailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author 一一哥Sun
 * @Date Created in 2020/4/20
 * @Description Description
 */
@RestController
@RequestMapping("/mail")
public class MailController {

    @Autowired
    private IMailService iMailService;

    @GetMapping("/simple")
    public String sendSimpleMail() {
        iMailService.sendSimpleMail("309733895@qq.com", "邮件标题", "邮件内容.....机密");
        return "success";
    }

    @GetMapping("/html")
    public String sendHtmlMail() {
        iMailService.sendHtmlMail("309733895@qq.com", "邮件主题", "<h1>邮件主题</h1><br/><p><font color='red'>邮件内容</font></p>");
        return "success";
    }

    @GetMapping("/attachment")
    public String sendAttachmentMail() {
        iMailService.sendAttachmentsMail("309733895@qq.com", "主题:带附件的邮件", "有附件的邮件,不要错过哦...", "static/touxiang.png");
        return "success";
    }

    @PostMapping("/model")
    public String sendModelMail(@RequestBody Employee employee) {
        iMailService.sendModelMail("309733895@qq.com", "主题:新员工入职欢迎邮件--模板邮件", "mail.ftl", employee);
        return "success";
    }

}
